using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MBMC.Dialogs.IO
{
    public partial class RemoveTempFiles : Form
    {
        string[] filepathslocal;
        public RemoveTempFiles(string[] filepaths)
        {
            InitializeComponent();
            filepathslocal = filepaths;
        }

        private void RemoveTempFiles_Load(object sender, EventArgs e)
        {
            foreach(string path in filepathslocal)
            {
                listBox1.Items.Add(path);
            }
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            System.IO.FileInfo fi = new System.IO.FileInfo(listBox1.SelectedItem.ToString());
            label3.Text = fi.Name;
            label4.Text = fi.CreationTime.ToString();
            label6.Text = fi.Length.ToString() + " bytes";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.IO.File.Delete(listBox1.SelectedItem.ToString());
            //listBox1.Items.Remove(listBox1.SelectedItem);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            foreach(string item in listBox1.Items)
            {
                System.IO.File.Delete(item);
                
            }
            listBox1.Items.Clear();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}